package WaiBao;

import java.util.Arrays;

public class SangCheng {
    public static void main(String[] args) {
        String[] name = {"欧阳(班长)", "张大大(副班长)", "小李(学习委员)", "滴滴(体育委员)", "吴奇隆", "张晓华", "苏有朋", "李光耀", "李大鹏", "绣花针", "张秀秀", "王朗",
                "张小英", "刘中英", "李浩", "张旭", "小锦儿", "达达", "胖墩", "刘虎", "王兆坤", "李道华", "卢强", "李文", "李玟", "李星", "李青", "王不求",
                "倪好", "桑柽(团支书)"};//考生本人:桑柽(团支书)
        int[] age = {20, 19, 21, 20, 19, 21, 18, 21, 20, 20, 18, 18, 18, 21, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 21, 20,19};//考生年龄：19

        double[] nuanhu1 = {77, 73, 85, 81, 80, 69, 78, 85, 81, 74, 91, 87, 85, 74, 61, 78, 69, 69, 75, 88, 92, 91, 95, 85, 75, 74, 77, 84, 91, 94};
        double[] nuanhu2 = {78, 55, 89, 84, 78, 71, 85, 79, 65, 80, 90, 67, 76, 75, 67, 65, 84, 69, 66, 75, 82, 71, 84, 87, 75, 84, 78, 75, 81, 95};
        double[] nuanhu3 = {67, 80, 81, 75, 79, 99, 68, 89, 80, 60, 83, 87, 85, 65, 65, 68, 89, 67, 94, 93, 94, 81, 85, 85, 76, 84, 73, 81, 84, 95};


        double reli1;//代表每个学生的总分
        double reli2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            reli1 = nuanhu1[i] +nuanhu2[i] +nuanhu3[i];
//            reli2 = (reli1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + reli1);
//            System.out.println(name[i] + "的平均分为:" +reli2);
//        }

        double mabu1 = 0, mabu2 = 0;
        double[] arr = new double[30];
//        for (int i = 0; i < 30; i++) {
//            mabu1 = nuanhu1[i] + nuanhu2[i] + nuanhu3[i];
//            mabu2  = (mabu1 * 1.0) / 3;
//            arr[i] = mabu2 ;
//        }
//
//        for (int i = 0; i < arr.length - 1; i++) {
//            for (int j = 0; j < arr.length - i - 1; j++) {
//                if (arr[j] < arr[j + 1]) {
//                    double tep = arr[j];
//                    arr[j] = arr[j + 1];
//                    arr[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(arr[i]);
//        }


        double cat1 = 0, cat2 = 0,cat3 = 0;//计算每门课的平均分
        double fish1 = 0, fish2 = 0,fish3 = 0;//计算每门课标准差
        double mugu1 = 0, mugu2 = 0,mugu3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < nuanhu1.length; i++) {
            sum2+=nuanhu1[i];
        }
        cat1 = (sum2*1.0)/30;
        System.out.println("农业设施及环境调控的班级平均分为:"+cat1);
        double Sum = 0;
        for (int i = 0; i < nuanhu2.length; i++) {
            Sum+=nuanhu2[i];
        }
        cat2 = (Sum*1.0)/30;
        System.out.println("农业设施设计与建造的班级平均分为:"+cat2);
        double sum = 0;
        for (int i = 0; i <nuanhu3.length; i++) {
            sum+=nuanhu3[i];
        }
        cat3 = (sum*1.0)/30;
        System.out.println("园艺植物设施栽培学的班级平均分为:"+cat3);



        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < nuanhu1.length; i++) {
            c1+= (nuanhu1[i] -cat1)*(nuanhu1[i] - cat1);
        }
        fish1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:"+fish1);

        for (int i = 0; i < nuanhu2.length; i++) {
            c2+= (nuanhu2[i] -cat2)*(nuanhu2[i] - cat2);
        }
        fish2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:"+fish2);

        for (int i = 0; i < nuanhu3.length; i++) {
            c3+= (nuanhu3[i] - cat3)*(nuanhu3[i] - cat3);
        }
        fish3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的班级标准差为:"+fish3);
//////
        Arrays.sort(nuanhu1);
        Arrays.sort(nuanhu2);
        Arrays.sort(nuanhu3);
        mugu1 =( nuanhu1[15]+nuanhu1[14])*1.0/2;
        mugu2 =( nuanhu2[15]+nuanhu2[14])*1.0/2;
        mugu3 =(nuanhu3[15]+nuanhu3[14])*1.0/2;
        System.out.println("农业设施及环境调控的中位数为:"+mugu1);
        System.out.println("业设施设计与建造的中位数为:"+mugu2);
        System.out.println("园艺植物设施栽培学的中位数为:"+mugu3);


    }
}
